package com.pkk.cloud.support.oauth2.client.url.dynamic;

import org.springframework.beans.BeansException;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

/**
 * @Description: apollo的动态配置
 * @Author: peikunkun
 * @Date: 2020/3/19 0019 下午 4:05
 */
@ConditionalOnProperty(name = "security.ignore.enable", havingValue = "true")
public class DynamicIgnoreUrlConfiguration implements ApplicationContextAware {

  public final static String namespaces = "ignore-url";

  private ApplicationContext applicationContext;

  /*@ApolloConfigChangeListener(namespaces)
  private void onChange(ConfigChangeEvent changeEvent) {
    refreshProperties(changeEvent.changedKeys());
  }

  private void refreshProperties(Set<String> changedKeys) {
    log.info("Refreshing ignore url: {}", changedKeys);
    this.applicationContext.publishEvent(new EnvironmentChangeEvent(changedKeys));
  }*/

  @Override
  public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
    this.applicationContext = applicationContext;
  }
}
